<meta name="content-type" content="text/html; charset=UTF-8" />
<div class="panel-heading panel-result-title">
	<h3 class="panel-title">查询结果</h3>
	<div id="product_operator"
		class="btn-group btn-group-sm btn-gp-default">
		<button id="btn_add" type="button"
			class="btn btn-default panel-radius-left">添加</button>
		<button id="btn_edit" type="button"
			class="btn btn-default panel-radius-none">修改</button>
		<button id="btn_delete" type="button"
			class="btn btn-default panel-radius-right">删除</button>
	</div>
</div>

<!-- #set(PaginatedList<Groups> memberGroups) -->
<!--
		#set(
		pager = memberGroups.pager,
		totalResults = pager.getCountOfTotalResults(),
		totalPages = pager.getCountOfTotalPages() * 1,
		pageSize = pager.pageSize,
		pageNo = pager.pageNo,
		prePageNo = pager.getPrevPageNo(),
		nextPageNo = pager.getNextPageNo()
		)
-->
<!--#if(memberGroups)-->
<table class="table table-bordered table-hover table-condensed tb"
	style="text-align: center;">
	<tr>
		<td width="100"><input id="chkallIds" type="checkbox" /></td>
		<td width="435">组名</td>
		<td width="435">备注</td>
		<td width="200">创建时间</td>
	<tr>
		<!--#for(Groups group : memberGroups)-->
	<tr>
		<td><input name="chk_name" type="checkbox" value="${group.id}" /></td>
		<td>${group.name}</td>
		<td>${group.remarks}</td>
		<td>${group.createtime}</td>
	</tr>
	<!--#end-->
</table>
<!-- 列表分页 -->
<div class="paging-page">$!{include("paging_page.html")}</div>
<!-- #else -->
<div class="panel-body">没有符合条件的数据</div>
<!-- #end -->
<script type="text/javascript">
	var ids = new Array();
	$(function() {
		//删除
		$("#btn_delete").click(function() {
			/* var checklist = document.getElementsByName("chk_name");
			var ids = "";
			for (var i = 0; i < checklist.length; i++) {
				if (checklist[i].checked) {
					ids = ids + checklist[i].value + ",";
				}
			} */
			
			var len = $("input[name='chk_name']:checked").length;
			len = len * 1;
			
			if (len <= 0) {
				alert("请选择要删除的行");
			} else {
				$("input[name='chk_name']:checked").each(function() {
					var id = $(this).val();
					ids.push(id);
				});
				var Ids = ids.join(",");
				confirm("确定要删除吗", function() {
					this.close();
					var d = wait("正在删除，请稍候...");
					var url = "yueyogaAdmin/deleteMemberGroupsByIds.jhtml";
					$.post(
						url, 
						{"ids": Ids},
						function(response) {
							if (response == "true") {
								d.content("删除成功");
								setTimeout(function(){
									d.close().remove();
								}, 300);
								$("form[name='memberGroupForm']").submit();
							} else {
								error("删除失败!");
							}
						}
					);
				});
			}
			ids = new Array();
		});
		$("#btn_edit").click(function() {
			$('input[name="chk_name"]:checked').each(function() {
				ids.push($(this).val());
			});
			if (ids.length == 1) {
				window.location.href = "yueyogaAdmin/toEditMemberGroup.jhtml?groupId=" + ids;
			} else {
				alert("请选择一条记录进行修改!");
			}
			ids = [];
		});
		//--全选`反选
		$("#chkallIds").click(function() {
			if (this.checked) {
				$("input[name='chk_name']").each(function() {
					this.checked = true;
				});
			} else {
				$("input[name='chk_name']").each(function() {
					this.checked = false;
				});
			}
		});

		$("#btn_add").click(function() {
			window.location.href = "yueyogaAdmin/toAddMemberGroup.jhtml";
		});
	});
</script>